home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10780 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: EU.net!sun4nl!xs4all!falstaff
  2. From: falstaff@xs4all.nl (Falstaff)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: fscanf problem
  5. Date: 19 Mar 1996 19:51:44 GMT
  6. Organization: XS4ALL, networking for the masses
  7. Message-ID: <4in38g$9rt@news.xs4all.nl>
  8. References: <1996Mar19.184044@omega.ntu.ac.sg>
  9. NNTP-Posting-Host: xs1.xs4all.nl
  10. X-Newsreader: NN version 6.5.0 #666 (NOV)
  11.  
  12. sg7248613@omega.ntu.ac.sg writes:
  13.  
  14. >I have been trying to read a section of data from a file for days.
  15.  
  16. >The data segment goes like this:
  17. >    .....
  18. >    Patch norm0 4 { { 0 -1 0 } { 0 -1 0 } { 0 -1 0 } { 0 -1 0 } }
  19. >    Patch vert0 4 { { 0 1 0 } { 1 1 0 } { 1 1 1 } { 0 1 1 } }.
  20.                                                               ^^
  21. what's that period doing there?
  22.  
  23. >    .....
  24. >My actual code segment is as follows:
  25.  
  26. >fscanf(meshf, "    Patch %s %d { { %f %f %f } { %f %f %f } { %f %f %f }\
  27. >            { %f %f %f } }\n    Patch %s %d { { %f %f %f } { %f %f %f }\
  28. >            { %f %f %f } { %f %f %f } }\n", pptr->nname, &(pptr->numVert),
  29. >            &tmpf[0], &tmpf[1], &tmpf[2], &tmpf[3], &tmpf[4], &tmpf[5],
  30. >            &tmpf[6], &tmpf[7], &tmpf[8], &tmpf[9], &tmpf[10], &tmpf[11],
  31. >            pptr->vname, &tmpi,
  32. >            &tmpg[0], &tmpg[1], &tmpg[2], &tmpg[3], &tmpg[4], &tmpg[5],
  33. >            &tmpg[6], &tmpg[7], &tmpg[8], &tmpg[9], &tmpg[10], &tmpg[11]);
  34.  
  35. >The read of the first line is OK. But I can't scanf the second line
  36. >successfully. Could anyone please enlighten me on this? Thank you!
  37.  
  38. What value is returned by fscanf()?  That's a useful diagnositc.
  39.  
  40. First, remove the \n in your control string -- that shouldn't
  41. be there.  If you want to be sure only one line is read, then
  42. fgets() the line first, and then sscanf() on your line buffer.
  43.  
  44. Frank
  45. --
  46. The famous GIICM now on line:  http://www.xs4all.nl/~falstaff/GIICM.html
  47. ------------------------------------------------------------------------
  48. Frank A. Vorstenbosch        +31-(70)-355 5241        falstaff@xs4all.nl
  49.